<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Find Rule</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<STYLE> .menu{font:menu}
</STYLE>
</HEAD>
<SCRIPT language="javascript" src="/include/common.js"></SCRIPT>
<body MS_POSITIONING="GridLayout" style="MARGIN: 0px; BACKGROUND-COLOR: buttonface" onload="page_Load()" rightmargin="0px" bottommargin="0px">

<TABLE height="100%" border="0">
	<TR height="100%">
		<TD align="center" colspan="2" width="100%">
			<SELECT runat="server" id="selFields" multiple onclick="setTimeout(function(){showFindButton()},100)" ondblclick="findSelect()" style="HEIGHT: 100%"></SELECT>
		</TD>
	<TR>
		<TD width="80%">
			<INPUT style="width:100%" id="txtFind" onkeypress="if(event.keyCode==13)btnFind.click()">
		<TD width="20%">
			<INPUT type="button" value="Find"
						 onclick="txtFind.value?findText():findSelect()" id="btnFind" style="display:">
</TABLE>
</body>
</HTML>
<SCRIPT src="/include/Common.js"></SCRIPT>
<SCRIPT>
var fnFind = function(){alert('Find function is not initialized!')}
document.attachEvent("onkeypress",function(){if(event.keyCode == 27)close();});
//window.onresize = cropMe;
function page_Load(){
	fnFind = dialogArguments.fnFind;
	cropWindow();
	txtFind.focus();
	btnFind.setExpression("disabled","!hasCriteria()");
}
function findText(){return find("Text","("+txtFind.value+")")}
function findSelect(){return find("Label","("+getValues()+")")}
function find(attrName,text){
	if( !text )return alert("Select Rule Name!");
	selFields.style.cursor = "wait";
	disableAll();
	setTimeout(function(){fnFind(attrName,text);disableAll(true)},300);
}
function showFindButton(){
	if( getSelectionCount() > 1 )txtFind.value = "";
	return;
	for( var i=0,c=0; i < selFields.length; i++ )
		if( selFields[i].selected )c++;
	if( c < 2 && btnFind.style.display == "" ){
		btnFind.style.display = "none";
		cropWindow();
	}
	if( c > 1 && btnFind.style.display == "none" ){
		btnFind.style.display = "";
		external.dialogHeight = (parseInt(external.dialogHeight)+50)+"px";
		cropWindow();
	}
}
function getValues(){
	for(var a = [],i = 0; i < selFields.length; i++)
		if( selFields[i].selected )
			a.push(selFields[i].text.reEncode("."));
	return a.join("|");
}
function getSelectionCount(){
	for(var c = 0,i = 0; i < selFields.length; i++)
		if( selFields[i].selected )c++;
	return c;
}
function cropMe(){
	external.dialogHeight = (parseInt(external.dialogHeight)+30)+"px";
	cropWindow();
}
function disableAll(enable){
	selFields.disabled = txtFind.disabled = btnFind.disabled  = !enable;
	 selFields.style.cursor = txtFind.style.cursor = btnFind.style.cursor = enable ? "" : "wait";
}
function hasCriteria(){return selFields.selectedIndex>=0||txtFind.value}
</SCRIPT>
